package cn.iocoder.yudao.module.pay.splitting.pojo.vo;

import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.api.pay.splitting.enums.MallBookSplitStatusEnum;
import cn.iocoder.yudao.module.pay.splitting.enums.SplittingStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 *  这里是文件说明
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/05/17
 */
@Data
@Accessors(chain = true)
public class MallBookSplittingVO {

    @Schema(description = "支付单号")
    private String payNo;

    @Schema(description = "分账单号")
    private String splitNo;

    @Schema(description = "状态：0-等待确认、1-分账成功、2-分账失败、3-分账取消", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
    @InEnum(SplittingStatusEnum.class)
    private Integer status;

    @Schema(description = "渠道错误码")
    private String channelErrorCode;

    @Schema(description = "渠道错误消息")
    private String channelErrorMsg;

    @Schema(description = "渠道原始的同步/异步通知结果")
    private Object rawData;

    /**
     * 创建【WAITING】状态的订单返回
     */
    public static MallBookSplittingVO waitingOf(String payNo, String splitNo, Object rawData) {
        MallBookSplittingVO vo = new MallBookSplittingVO();
        vo.payNo = payNo;
        vo.splitNo = splitNo;
        vo.status = MallBookSplitStatusEnum.WAIT.getValue();
        vo.rawData = rawData;
        return vo;
    }

    /**
     * 创建【SUCCESS】状态的订单返回
     */
    public static MallBookSplittingVO successOf(String payNo, String splitNo, Object rawData) {
        MallBookSplittingVO vo = new MallBookSplittingVO();
        vo.payNo = payNo;
        vo.splitNo = splitNo;
        vo.status = MallBookSplitStatusEnum.SUCCESS.getValue();
        vo.rawData = rawData;
        return vo;
    }

    /**
     * 创建【FAILURE】状态的订单返回
     */
    public static MallBookSplittingVO failureOf(String payNo, String splitNo, String errorCode, String errorMsg, Object rawData) {
        MallBookSplittingVO vo = new MallBookSplittingVO();
        vo.payNo = payNo;
        vo.splitNo = splitNo;
        vo.status = MallBookSplitStatusEnum.FAILURE.getValue();
        vo.channelErrorCode = errorCode;
        vo.channelErrorMsg = errorMsg;
        vo.rawData = rawData;
        return vo;
    }

    /**
     * 创建【ERROR】状态的订单返回
     */
    public static MallBookSplittingVO errorOf(String payNo, String splitNo, String errorCode, String errorMsg, Object rawData) {
        MallBookSplittingVO vo = new MallBookSplittingVO();
        vo.payNo = payNo;
        vo.splitNo = splitNo;
        vo.status = MallBookSplitStatusEnum.ERROR.getValue();
        vo.channelErrorCode = errorCode;
        vo.channelErrorMsg = errorMsg;
        vo.rawData = rawData;
        return vo;
    }


}
